<?php
include_once("../DAO/UserDAO.php");
include_once("../Utility/WebUtilities.php");
include_once("../Utility/WebSession.php");

if(WebUtilities::GetQueryString("signout", 0) == 1)
{
	WebSession::SignOut();
}

$username = WebUtilities::GetQueryString("tbUsername", "");
$pass = WebUtilities::GetQueryString("tbPassword", "");
if($username != "" &&  $pass != "")
{
	$userDAO = new UserDAO();
	WebSession::SetCurrentUser($userDAO->Authentication($username, $pass));
	WebUtilities::Redirect("index.php");
}

$loginStr = "";
if(WebSession::CurrentUserNoReturn() == null)
{
	$loginStr = "<div class='loginPanel'>
					<div class='oneLine'>
						<div class='left1'>Username</div>
						<input class='right1' name='tbUsername' id='tbUsername'/>
					</div>
					<div class='oneLine'>
						<div class='left1'>Password</div>
						<input class='right1' type='password' name='tbPassword' id='tbPassword' />
					</div>
					<div class='oneLine' style='text-align:right;'>
						<div class='left1'>&nbsp;</div>
						<a class='loginButton' onclick='SubmitLogin()'>Login</a>
					</div>
				</div>";
}

$mainContent = "<div class='leftPanel'>	
				</div>
				<form enctype='multipart/form-data' action='index.php' method='POST'>
				<div class='rightPanel'>"
					. $loginStr . 
					"<a class='trainChoose' onclick=\"window.location='MainTest.php?type=0'\"><img src='../images/training.jpg' /></a><br/>
					<a class='testChoose' onclick=\"window.location='MainTest.php?type=1'\"><img src='../images/test.jpg' /></a>
				</div>
				</form>";
include("MasterPage.php");
?>